﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Work.Domain.DrugManage
{
    /// <summary>
    /// 检药单（药品检查记录）
    /// </summary>
    public class DrugInspection
    {
        /// <summary>
        /// 检药单ID（主键）
        /// </summary>
        [Key]
        public int InspectionId { get; set; }

        /// <summary>
        /// 处方明细ID（外键，关联PrescriptionItem表）
        /// 一个处方明细对应一个检药单
        /// </summary>
        public int PrescriptionItemId { get; set; }

        /// <summary>
        /// 预约编号（外键，关联Appintment表，冗余字段）
        /// </summary>
        public int AppointmentId { get; set; }

        /// <summary>
        /// 患者ID（外键，关联Patient表，冗余字段）
        /// </summary>
        public int PatientId { get; set; }

        /// <summary>
        /// 挂号编号（冗余字段，便于快速查询）
        /// </summary>
        [MaxLength(50)]
        public string? RegistrationNum { get; set; }

        /// <summary>
        /// 患者姓名（冗余字段）
        /// </summary>
        [MaxLength(100)]
        public string? PatientName { get; set; }

        /// <summary>
        /// 卡号（冗余字段）
        /// </summary>
        [MaxLength(50)]
        public string? CardNumber { get; set; }

        /// <summary>
        /// 药品ID（外键，关联Drug表，冗余字段）
        /// 从处方明细中获取药品信息
        /// </summary>
        public int? DrugId { get; set; }

        /// <summary>
        /// 药品名称（冗余字段）
        /// </summary>
        [MaxLength(100)]
        public string? DrugName { get; set; }

        /// <summary>
        /// 检查状态（待检查/已检查/已发药）
        /// </summary>
        [MaxLength(50)]
        public string? InspectionStatus { get; set; }

        /// <summary>
        /// 检查日期
        /// </summary>
        public DateTime? InspectionDate { get; set; }

        /// <summary>
        /// 检查人（执行检查操作的人员）
        /// </summary>
        [MaxLength(50)]
        public string? Inspector { get; set; }

        /// <summary>
        /// 检查结果（正常/过期/损坏等）
        /// </summary>
        [MaxLength(200)]
        public string? InspectionResult { get; set; }

        /// <summary>
        /// 处理方式（继续使用/报废/退回等）
        /// </summary>
        [MaxLength(200)]
        public string? HandlingMethod { get; set; }

        /// <summary>
        /// 是否已发药（已发药/未发药）
        /// </summary>
        public bool IsDispensed { get; set; } = false;

        /// <summary>
        /// 发药日期（可选）
        /// </summary>
        public DateTime? DispensedDate { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }

        // 导航属性
        /// <summary>
        /// 关联的处方明细信息
        /// </summary>
        public virtual PrescriptionItem? PrescriptionItem { get; set; }

        /// <summary>
        /// 关联的预约信息
        /// </summary>
        public virtual Appintment? Appointment { get; set; }

        /// <summary>
        /// 关联的患者信息
        /// </summary>
        public virtual Patient? Patient { get; set; }

        /// <summary>
        /// 关联的药品信息
        /// </summary>
        public virtual Drug? Drug { get; set; }
    }
}
